package cn.smile.controller.basic;

import cn.smile.bean.dto.basic.MyShopDTO;
import cn.smile.bean.form.basic.shop.SavePositionForm;
import cn.smile.bean.form.basic.shop.SaveShopForm;
import cn.smile.business.basic.IMyShopService;
import cn.smile.commons.response.MyResult;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;

@RestController
@RequestMapping("api/myShop")
public class MyShopController {

    @Resource
    private IMyShopService service;

    @GetMapping(value = "initShop")
    public MyResult<String> initShop(@RequestParam("managerId") String managerId) {
        return MyResult.OK(service.initShop(managerId));
    }

    @GetMapping(value = "bindShop")
    public MyResult<Boolean> bindShop(@RequestParam("shopCode") String shopCode) {
        return MyResult.OK(service.bindShop(shopCode));
    }

    @GetMapping(value = "getMyShop")
    public MyResult<MyShopDTO> getMyShop() {
        return MyResult.OK(service.getMyShop());
    }

    @PostMapping(value = "saveShop")
    public MyResult<Boolean> saveShop(@Valid @RequestBody SaveShopForm form) {
        return MyResult.OK(service.saveShop(form));
    }

    @PostMapping(value = "savePosition")
    public MyResult<Boolean> savePosition(@Valid @RequestBody SavePositionForm form) {
        return MyResult.OK(service.savePosition(form));
    }

    @GetMapping(value = "relieveBind")
    public MyResult<Boolean> relieveBind(@RequestParam("userId") String userId){
        return MyResult.OK(service.relieveBind(userId));
    }
}
